import threading
from time import sleep

from loguru import logger

# 定义全局变量
my_list = []


def write_data():
    """写入数据"""
    for i in range(3):
        my_list.append(i)
    logger.info(my_list)


def read_data():
    """读取数据"""
    logger.info(my_list)


if __name__ == '__main__':
    write_thread = threading.Thread(target=write_data)
    read_thread = threading.Thread(target=read_data)

    write_thread.start()
    sleep(1)
    read_thread.start()
